<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="utf-8">
    <title>团队申请</title>
    <link rel="stylesheet" type="text/css" href="/css/zui.min.css">
    <script src="/js/jquery.js"></script>
    <script src="/js/zui.min.js"></script>
    <script src="/js/base.js"></script>
    <script type="text/javascript">
        document.getElementsByTagName("html")[0].style.fontSize = document.documentElement.clientWidth/10 + "px";
        $(function(){
            var sub = 0;
            $('#sub').click(function(){
                var tel = $('#tel').val();
                var nickname = $('#nickname').val();
                var yzm = $('#yzm').val();
                if(!nickname){
                    $('#message').html('请输入昵称');
                    return false;
                }
                if(!tel){
                    $('#message').html('请输入电话号码');
                    return false;
                }
                if(!yzm){
                    $('#message').html('请输入短信码');
                    return false;
                }
//                $.post("/check_yzm_do", {yzm : yzm}, function(result){
//                    if(result != 'success'){
//                        $('#message').html('短信码不正确, 请重试');
//                        return false;
//                    }else{
//                        $('#form').submit();
//                    }
//                });
                if(sub == 0){
                    sub = 1;
                    $('#form').submit();
                }
            });
            $('#send_yzm').click(function(){
                var phone = checkPhone($('#tel').val());
                if(phone){
                    $('#send_yzm').attr("disabled", "disabled");
                    $('#send').html('已发送');
                    $('#send').css('color','yellow');
                    $.post("/send_yzm_do", {tel : $('#tel').val(), sign : $('#sign').val()}, function(result){
                        if(result == 'tel'){
                            $('#message').html('您已经是我们的会员啦');
                        }
                    });
                }else{
                    $('#message').html('请输入正确的电话号码');
                    return false;
                }
            });

        });
        function checkPhone(tel){
            if(tel.length==11){
                return true;
            }
            return false;
        }
    </script>

    <link rel="stylesheet" type="text/css" href="/css/master.css">
</head>
<body>
<form method="post" action="/sale_register_do" id="form" enctype="multipart/form-data">
    <div class="column">
        <p id="message" style="color: red;"></p>
        <p>昵称：</p>
        <input type="text" class="txt" name="nickname" id="nickname" placeholder="请输入您的昵称">
        <p>手机号：</p>
        <input type="text" class="num" id="tel" name="tel" placeholder="请输入您的手机号">
        <button class="btn1" id="send_yzm" onsubmit="return false" type="button"><span class="btn-text" id="send">发送验证码</span></button>
        <p>短信码：</p>
        <input type="text" class="txt" id="yzm" name="yzm" placeholder="请输入手机上收到的短信码">
        <input type="hidden" id="sign" name="sign" value="${sign}"/>
        <input type="hidden" name="sale" value="1"/>
        <button class="btn2" id="sub" type="button"><span class="btn-text">成为会员</span></button>
    </div>
</form>
</body>
</html>